treeview: Use _gtk_rbtree_contains() in a11y code
authorBenjamin Otte <otte@redhat.com>
Sat, 10 Dec 2011 01:03:46 +0000 (02:03 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 10 Dec 2011 07:00:25 +0000 (08:00 +0100)
gtk/a11y/gtktreeviewaccessible.c

index 44c8a772222a9017db2e1e24af5a206e170248bf..407954122588ed63aae27c0cc6a25a16b3a6a032 100644 (file)
@@ -3093,35 +3093,6 @@ get_header_from_column (GtkTreeViewColumn *tv_col)
   return rc;
 }
 
-/**
- * _gtk_rbtree_get_ancestor_node:
- * @ancestor: the ancestor tree
- * @child_tree: the potential child's tree
- * @child_node: the potential child's node
- *
- * Finds the node that is the ancestor of @child_tree and @child_node
- * and belongs to @ancestor. If @ancestor is not an ancestor tree
- * of @child_node, %NULL is returned.
- *
- * Returns: the ancestor node or %NULL if @ancestor is not an ancestor.
- **/
-static GtkRBNode *
-_gtk_rbtree_get_ancestor_node (GtkRBTree *ancestor,
-                               GtkRBTree *child_tree,
-                               GtkRBNode *child_node)
-{
-  while (child_tree != NULL)
-    {
-      if (child_tree == ancestor)
-        return child_node;
-
-      child_node = child_tree->parent_node;
-      child_tree = child_tree->parent_tree;
-    }
-
-  return NULL;
-}
-
 void
 _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
                                   GtkRBTree   *tree,
@@ -3137,17 +3108,15 @@ _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
 
   /* if this shows up in profiles, special-case node->children == NULL */
 
+  if (node != NULL)
+    tree = node->children;
+
   g_hash_table_iter_init (&iter, accessible->cell_infos);
   while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
     {
-      GtkRBNode *child_node = _gtk_rbtree_get_ancestor_node (tree,
-                                                             cell_info->tree,
-                                                             cell_info->node);
-
-      if (child_node == NULL)
-        continue;
-
-      if (node == NULL || node == child_node)
+      if (node == cell_info->node ||
+          tree == cell_info->tree ||
+          (tree && _gtk_rbtree_contains (tree, cell_info->tree)))
         g_hash_table_iter_remove (&iter);
     }
 }